package com.fxu.framework.mq.rabbit;

//import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.ExchangeTypes;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.*;
//import org.springframework.messaging.handler.annotation.Headers;
//import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

/**
 * @author fangxu
 *
 *       消息接收者
 *       1、@RabbitListener bindings:绑定队列
 *       2、@QueueBinding
 *    value:绑定队列的名称、exchange:配置交换器、key:路由键routing-key绑定队列和交换器
 *       3、@Queue value:配置队列名称、autoDelete:是否是一个可删除的临时队列
 *       4、@Exchange value:为交换器起个名称、type:指定具体的交换器类型
 *
 * @version 1.0
 */


@Slf4j
//@Component
public class RabbitMqConcumer {
//    /**
//     * 取消订单队列
//     */
//    @RabbitListener(id = "rmq.id.${rmq.id}",
//        bindings = @QueueBinding(
//            value = @Queue(value = "rmq.id.${rmq.id}", durable = "true"),
//            exchange = @Exchange(value = "rmq.key.${rmq.exchange}", type = ExchangeTypes.TOPIC),
//            key = "rmq.key.${rmq.key}"
//        )
//    )
//    @RabbitHandler
//    public void complateOrder(@Payload String retData, Message message, Channel channel, @Headers Map<String,Object> map) throws IOException {
//        //MatchCompleteOrder matchComplateOrder = JSONUtil.toBean(retData, MatchCompleteOrder.class);
//        //log.info("MQ_QUEUE_ORDER_COMPLETED complate 收到 deliveryTag:{} matchComplatOrder :{} ", map.get(AmqpHeaders.DELIVERY_TAG), matchComplateOrder);
//        try {
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//        } catch (Exception ex) {
//            log.error("retData:{}", retData, ex);
//            //丢弃这条消息
//            channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
//            log.info("ACK_QUEUE_A 接受信息异常");
//        }
//    }

}